package cn.zhiquxing.service;


import cn.zhiquxing.dao.UserDao;
import cn.zhiquxing.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserBatchServiceImpl implements UserBatchService {
    
    @Autowired
    private UserDao userDao;
    
    @Autowired
    private UserService userService;
    @Override
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public int insertUsers2(List<User> users) {
        int count = 0;
        for (User user : users) {
            try {
                count += userService.insertUser(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return count;
    }
}
